February 2, 1996
I know, I know. You're wondering why Dr. GUI hasn't written squat since, ulp, November 1. Well, a couple reasons: As you probably recall, Dr. GUI has gone through a lot of, oh, let's call them "personal identity problems" during the last year. First, "he" became a "she." Then, "she" became a toaster. (Don't ask.) But, thanks to a desert retreat, the doctor has been feeling like his good old self.
But, more importantly, Dr. GUI hasn't been hearing from NEARLY enough of you, pouring your code-filled hearts out with the thorniest problems on all aspects of Windows development.
So, now that he's cured himself, the good doctor has done what any self-respecting, hot-wired, online doctor of the '90's does. He's got himself his very own, private Dr. GUI E-MAIL ALIAS .
Quick now, fire off a stumper question to the 'ole doctor by clicking the 8-ball
If you still believe in those musty, low-tech ways of consulting with the doc, you can use the postal address: Ask Dr. GUI, c/o Microsoft Developer Network, One Microsoft Way, Redmond, WA 98052-6399
I started hacking on my own private version of Windows 95 and added the WM_REGENERATE message. What a mistake that was! In my first sample application using this message, I inadvertently added the following code:
switch (message) { case WM_MOUSEMOVE: SendMessage(hwnd, WM_REGENERATE, wParam, lParam); break;
This has led to much inconvenience. Last column I was a woman; this column I appear to be a toaster. One second, do you smell smoke? Probably just from my editor's office. Anyway, I wonder what I will be in the next column, toast?
Dear Dr. GUI:
We're finding that under Windows 95, if you use the "Start->Shutdown->Close all Programs and Logon as different user" option to log out of Windows and log back on, the destructors for our App/Doc/Frame/... don't get called!
I guess I could either SendMessage(WM_CLOSE) to the frame during OnEndSession or DestroyWindow the frame there, but that still means the application's destructor won't be called. (Luckily, we aren't doing much of anything in the app destructor--most of the work is in our doc's constructor, which should be called with this workaround, me thinks.)
Gman
Dr. GUI replies:
Destructicons. Obviously a play on my kid's toy Decepticons. These are little toy trucks, forklifts, and Cessna airplanes that unfold into robots. My kid loves them. I despise them. Each morning I run the gauntlet from my bed to the bathroom, dodging the stupid things, wondering if I had a tetanus shot recently. These silly things even have names: Optimus Prime, Trashcan, Prime Directive, Destined-for-garbage. Perhaps I should talk about destructors.
Yes, the destructors for the applications are not being called. The idea is that a user wants to exit Windows 95 without watching all 20 programs that are running disappear from the desktop one-by-one.
Sending WM_CLOSE would be pretty sloppy, as the user will notice your application disappear from the desktop before the desktop goes away, which would be different from other applications out there. The following suggestions will help you clean up after yourself in a reliable way:
Dear Dr. GUI:
When I use the Courier New font, at some font sizes some glyphs are showing up with missing pixels. The problem is reproducible. It usually happens when the glyph is one pixel in width or height. Is this a bug with the font hinting? Here is a bitmap illustrating what is happening.
And here is the code that produced this effect:
case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); RECT rect; HFONT hf, hfOld; GetClientRect(hWnd, &rect); SetMapMode(hDC, MM_ISOTROPIC); SetWindowExtEx(hDC, 1250, 1250, NULL); SetViewportExtEx(hDC, rect.right, rect.bottom, NULL); SetViewportOrgEx(hDC, 0,0,NULL); hf = CreateFont(3000/7, 3000/30, 0, 0, FW_DEMIBOLD, 0, 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Courier New"); hfOld = SelectObject(hDC, hf); TextOut(hDC,500,500,"This is a test of font scaling", strlen("This is a test of font scaling")); SelectObject(hDC, hfOld); DeleteObject(hf); EndPaint(hWnd, &ps); } break;
Dr. GUI replies:
I have always been fascinated with hieroglyphics, although I have to admit that I generally associate them with the Mummy (the monster, not Billy). This of course makes me think of my childhood days watching horror movies. I would, without fail, find myself cowering behind the gray-and-salmon overstuffed chair just waiting for the door to crash in as the Mummy, Frankenstein, or Wolfman sought to rip the arms and legs off my puny nine-year-old frame. Whoa, did you hear something? Was that your door or mine?!
This problem can be the result of a number of factors, including: